package com.atguigu.e_reflect;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException {
        //获取学生类的字节码对象
        //类名.class
        Class<Student> clazz1 = Student.class;

        //对象名.getClass()
        Student stu = new Student();
        Class<? extends Student> clazz2 = stu.getClass();

        //Class.forName("类的全类名")
        Class<?> clazz3 = Class.forName("com.atguigu.e_reflect.Student");


        System.out.println("clazz1 = " + clazz1);
        System.out.println("clazz2 = " + clazz2);
        System.out.println("clazz3 = " + clazz3);

        //一个类的字节码对象只有一个
        System.out.println("clazz1 == clazz2 = " + (clazz1 == clazz2));
        System.out.println("clazz1 == clazz3 = " + (clazz1 == clazz3));
        System.out.println("clazz2 == clazz3 = " + (clazz2 == clazz3));
    }
}
